<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Selector Test</title>
</head>
<body>
<script src="../test/test.js"></script>
<script>
    KISSY.Test.Config.times = 50;
</script>

<h2>Test Data</h2>

<script src="../../build/seed/seed-pkg.js"></script>
<script src="../../build/ua/ua-pkg.js"></script>

<script src="dom.js"></script>
<script src="selector.js"></script>
<script src="dom-data.js"></script>
<script src="dom-class.js"></script>
<script>KISSY.add('core');</script>

<script src="../../build/sizzle/sizzle-pkg.js"></script>

<script src="../../tools/third-party/jquery.js"></script>

<div id="test-data-div" style="width: 500px; height: 200px; overflow: auto; border: 1px solid #aaa"></div>
<textarea id="test-data-area" style="display: none" rows="0" cols="0">
<div id="test-data">
<!-- Generated from data/mast-home.php, ../../smarty/{mast.tpl} -->
<div id="w3c_mast"><!-- #w3c_mast / Page top header -->
    <h1 class="logo">W3C</h1>
</div>
<!-- /end #w3c_mast -->
<div id="w3c_main">
<div class="w3c_leftCol" id="w3c_logo_shadow"></div>
<div class="w3c_leftCol">
    <h2 class="offscreen">Site Navigation</h2>
    <h3 class="category"><span class="ribbon"><a href="/standards/">Standards </a></span></h3>
    <ul class="theme">
        <li class="design"><a title="HTML5, XHTML, and CSS, Scripting and Ajax, Web Applications, Graphics, Accessibility" href="/standards/webdesign/">
            <span class="icon"><!-- --></span>Web Design and
            Applications</a></li>
        <li class="arch"><a title="Architecture Principles, Identifiers, Protocols, Meta Formats" href="/standards/webarch/"><span class="icon">
<!-- --></span>Web Architecture</a></li>
        <li class="semantics"><a title="Data, Ontologies, Query, Linked Data" href="/standards/semanticweb/"><span class="icon">
<!-- --></span>Semantic Web</a></li>
        <li class="xml"><a title="XML Essentials, Semantic Additions to XML, Schema, Security" href="/standards/xml/"><span class="icon">
<!-- --></span>XML Technology</a></li>
        <li class="services"><a title="Data, Protocols, Service Description, Security" href="/standards/webofservices/"><span class="icon"><!-- --></span>Web of Services</a></li>
        <li class="devices"><a title="Voice Browsing, Device Independence and Content Negotation, Multimodal Access, Printing" href="/standards/webofdevices/">
            <span class="icon"><!-- --></span>Web of Devices</a></li>
        <li class="browsers"><a title="Browsers and User Agents, Authoring Tools, Web Servers" href="/standards/agents/"><span class="icon">
<!-- --></span>Browsers and Authoring Tools</a></li>
        <li class="allspecs"><a href="/TR/"><span class="icon">
<!-- --></span>… or view all</a></li>
    </ul>
    <h3 class="category tMarginLg"><span class="ribbon"><a href="Consortium/mission.html#principles">Web for All </a></span></h3>
    <ul class="theme">
        <li><a href="Consortium/siteindex.html#technologies" title="Popular links to W3C technology information">W3C
            A&nbsp;to&nbsp;Z</a></li>
        <li><a href="/WAI/">Accessibility</a></li>
        <li><a href="/International/">Internationalization</a></li>
        <li><a href="/Mobile/">Mobile Web</a></li>
        <li><a href="/2007/eGov/">eGovernment</a></li>
        <li><a href="/2008/MW4D/">Developing Economies</a></li>
    </ul>
</div>
<div class="w3c_mainCol">
<div id="w3c_crumbs">
    <div id="w3c_crumbs_frame">
        <p class="bct"><span class="skip"><a href="#w3c_most-recently" title="Skip to content (e.g., when browsing via audio)" accesskey="2" tabindex="1">Skip</a></span></p>
        <br></div>
</div>
<div class="line">
<div class="unit size2on3">
    <div class="main-content">
        <h2 class="offscreen">News</h2>
        <div id="w3c_slideshow">
            <div class="intro hierarchy vevent_list" id="w3c_most-recently">

                <div class="event w3c_topstory expand_block">
                    <div class="headline">
                        <h3 class="h4 tPadding0 bPadding0 summary">
                            <span class="expand_section"><a href="#">Interested in Next Steps for RDF? Come to the W3C Workshop!</a></span>
                        </h3>
                        <p class="date"><span title="2010-01-20T17:41:04-05:00" class="dtstart published">20 January 2010</span>
                            | <a href="/News/2010#entry-8699" title="Archive: Interested in Next Steps for RDF? Come to the W3C Workshop!">Archive</a>
                        </p>
                    </div>
                    <div class="description expand_description">
                        <p>W3C is organizing a
                            <a href="/2009/12/rdf-ws/cfp">Workshop on the Next Steps for RDF</a> around June 2010; we will announce the exact dates and location as soon as possible. Since its publication in 2004, the <a href="/TR/2004/REC-rdf-concepts-20040210/">Resource
                                Description Framework (RDF)</a> has become the core architectural block of the <a href="/2001/sw/">Semantic Web</a>. The standard is now widely deployed in terms of tools and applications. Due to this wide deployment, additional R&amp;D activities, and the publication of newer standards (e.g., <a href="/TR/rdf-sparql-query/">SPARQL</a>,
                            <a href="/TR/owl2-overview/">OWL</a>, <a href="/TR/powder-primer/">POWDER</a>, and <a href="/TR/skos-reference">SKOS</a>), a number of
                            issues regarding RDF have come to the fore. Workshop articipants
                            will discuss these issues and help determine whether it is time for a new version of RDF.
                            W3C Membership is not required to participate
                            in the Workshop, but each participant must be associated with an accepted
                            position paper. The deadline for position papers is 29 March 2010; see the <a href="/2009/12/rdf-ws/cfp">Call for Participation</a> for
                            more information. Updates (including the exact date and location of the Workshop) will be added to the Call for Participation and will be announced on the <a href="/2001/sw/anews">Semantic Web Activity News Blog</a>.</p>

                    </div>
                </div>


                <div class="event closed expand_block">
                    <div class="headline">
                        <h3 class="h4 tPadding0 bPadding0 summary"><span class="expand_section"><a href="#">Selectors API Level 2 First Draft Published</a></span></h3>
                        <p class="date"><span title="2010-01-19T16:08:40-05:00" class="published dtstart">19 January 2010</span>
                            | <a href="/News/2010#entry-8698" title="Archived: Selectors API Level 2 First Draft Published">Archive</a>
                        </p>
                    </div>
                    <div class="description expand_description">
                        <p>The <a href="/2008/webapps/">Web Applications Working Group</a> has published the First Public Working Draft of <a href="/TR/2010/WD-selectors-api2-20100119/">Selectors API Level 2</a>. Selectors, which are widely used in CSS, are patterns that match against elements in a tree structure. The Selectors API specification defines methods for retrieving Element nodes from the DOM by matching against a group of selectors, and for testing if a given element matches a particular selector. It is often desirable to perform DOM operations on a specific set of elements in a document. These methods simplify the process of acquiring and testing specific elements, especially compared with the more verbose techniques defined and used in the past. Learn more about the <a href="/2006/rwc/">Rich Web Client Activity</a>.</p>
                    </div>
                </div>

                <div class="event closed expand_block">
                    <div class="headline">
                        <h3 class="h4 tPadding0 bPadding0 summary"><span class="expand_section"><a href="#">Call for Review: WebCGM 2.1 Proposed Recommendation Published</a></span></h3>
                        <p class="date"><span title="2010-01-14T10:11:43-05:00" class="published dtstart">14 January 2010</span>
                            | <a href="/News/2010#entry-8696" title="Archived: Call for Review: WebCGM 2.1 Proposed Recommendation Published">Archive</a>
                        </p>
                    </div>
                    <div class="description expand_description">
                        <p>The <a href="/Graphics/WebCGM/WG/">WebCGM Working Group</a> has published a Proposed Recommendation of <a href="/TR/2010/PR-webcgm21-20100114/">WebCGM 2.1</a>. Computer Graphics Metafile (CGM) is an ISO standard, defined by ISO/IEC 8632:1999, for the interchange of 2D vector and mixed vector/raster graphics. WebCGM is a profile of CGM, which adds Web linking and is optimized for Web applications in technical illustration, electronic documentation, geophysical data visualization, and similar fields. WebCGM 2.1, refines and completes the features of the major WebCGM 2.0 release. WebCGM 2.0 added a DOM (API) specification for programmatic access to WebCGM objects, a specification of an XML Companion File (XCF) architecture, and extended the graphical and intelligent content of WebCGM 1.0. Comments are welcome through 11 February. Learn more about the <a href="/Graphics/">Graphics Activity</a>. <em>The review end date was corrected on 20 January.</em></p>
                    </div>
                </div>

                <div class="event closed expand_block">
                    <div class="headline">
                        <h3 class="h4 tPadding0 bPadding0 summary"><span class="expand_section"><a href="#">Programmable HTTP Caching and Serving Draft Published</a></span></h3>
                        <p class="date"><span title="2010-01-14T10:10:22-05:00" class="published dtstart">14 January 2010</span>
                            | <a href="/News/2010#entry-8695" title="Archived: Programmable HTTP Caching and Serving Draft Published">Archive</a>
                        </p>
                    </div>
                    <div class="description expand_description">
                        <p>The <a href="/2008/webapps/">Web Applications Working Group</a> has published a Working Draft of <a href="/TR/2010/WD-DataCache-20100114/">Programmable HTTP Caching and Serving</a>. This document defines APIs for off-line serving of requests to HTTP resources using static and dynamic responses. It extends the function of application caches defined in HTML5. Learn more about the <a href="/2006/rwc/">Rich Web Client Activity</a>.</p>
                    </div>
                </div>

                <div class="event closed expand_block">
                    <div class="headline">
                        <h3 class="h4 tPadding0 bPadding0 summary"><span class="expand_section"><a href="#"> W3C Advisory Committee Elects Technical Architecture Group Participants [CORRECTION]</a></span></h3>
                        <p class="date"><span title="2010-01-11T12:39:54-05:00" class="published dtstart">11 January 2010</span>
                            | <a href="/News/2010#entry-8694" title="Archived:  W3C Advisory Committee Elects Technical Architecture Group Participants [CORRECTION]">Archive</a>
                        </p>
                    </div>
                    <div class="description expand_description">
                        <p><em>Correction 13 January 2010</em> : The W3C Advisory Committee has elected Daniel Appelquist (Vodafone) and Henry Thompson (U. of Edinburgh) to the W3C <a href="/2001/tag/">Technical Architecture Group (TAG)</a>. The Director has appointed Ashok Malhotra (Oracle), Noah Mendelsohn, and Jonathan Rees. This outcome reflects the correct application of the tie-breaking algorithm.</p>


                        <p><em>Original message from 11 January:</em> The W3C Advisory Committee has re-elected Ashok Malhotra (Oracle) and Henry Thompson (U. of Edinburgh) to the W3C <a href="/2001/tag/">Technical Architecture Group (TAG)</a>. Continuing TAG participants are John Kemp (Nokia), Larry Masinter (Adobe), T.V. Raman (Google). The Director is also expected to appoint three individuals very soon. The <a href="/2004/10/27-tag-charter.html#Mission">mission</a> of the TAG is to build consensus around principles of Web architecture and to interpret and clarify these principles when necessary, to resolve issues involving general Web architecture brought to the TAG, and to help coordinate cross-technology architecture developments inside and outside W3C.</p>
                    </div>
                </div>

                <div class="event closed expand_block">
                    <div class="headline">
                        <h3 class="h4 tPadding0 bPadding0 summary"><span class="expand_section"><a href="#">New WAI Resource: Contacting Organizations about Inaccessible Websites</a></span></h3>
                        <p class="date"><span title="2010-01-06T09:16:51-05:00" class="published dtstart">06 January 2010</span>
                            | <a href="/News/2010#entry-8692" title="Archived: New WAI Resource: Contacting Organizations about Inaccessible Websites">Archive</a>
                        </p>
                    </div>
                    <div class="description expand_description">
                        <p>The Web Accessibility Initiative (WAI) Education and Outreach Working Group (<a href="/WAI/EO/">EOWG</a>) today published <strong><a href="/WAI/users/inaccessible">Contacting Organizations about Inaccessible Websites</a></strong> as part of the <a href="/WAI/WAI-AGE/">WAI-AGE Project</a>. This new WAI resource guides you through telling organizations about accessibility barriers on their website. WAI would like to know how this resource works for you and how we can improve it. See the blog post: <a href="/QA/2010/01/encourage_accessibility_make_a_difference.html">Take a few minutes to encourage web accessibility. Your voice counts</a>. <strong>Learn about <a href="/standards/webdesign/accessibility">Accessibility</a></strong> and visit the <a href="/WAI/">WAI home page</a>.</p>
                    </div>
                </div>

            </div>
        </div>
        <p class="noprint"><span class="more-news"><a title="More News" href="/News/archive">More news…</a></span></p>
        <div class="w3c_events_talks">
            <div class="line">
                <div class="unit size1on2">
                    <div class="w3c_upcoming_talks" id="w3c_home_talks"><h2 class="category"><a href="/Talks/" title="More Talks…">
                        Talks and Appearances
                    </a></h2>
                        <ul class="vevent_list">
                            <li class="vevent"><p class="date single"><span class="dtstart"><span class="year">2010</span><span class="mm-dd">-01-28</span></span> <span class="paren">(</span><span class="dd-mmm">28 JAN</span><span class="paren">)</span></p>
                                <div class="info-wrap"><p class="summary">Web Accessibility Promotion and Advocacy: Approaches and Resources</p><p class="source"> by Shawn Henry</p><p class="eventtitle"><a class="uri" href="http://www.atia.org/i4a/pages/index.cfm?pageid=3545">ATIA 2010 Orlando</a></p><p class="location">Orlando, FL,
                                    USA</p></div>
                            </li>
                            <li class="vevent"><p class="date single"><span class="dtstart"><span class="year">2010</span><span class="mm-dd">-01-29</span></span> <span class="paren">(</span><span class="dd-mmm">29 JAN</span><span class="paren">)</span></p>
                                <div class="info-wrap"><p class="summary">Web Accessibility Standards and Guidelines Update 2010</p><p class="source"> by Shawn Henry</p><p class="eventtitle"><a class="uri" href="http://www.atia.org/i4a/pages/index.cfm?pageid=3545">ATIA 2010 Orlando</a></p><p class="location">Orlando, FL,
                                    USA</p></div>
                            </li>
                            <li class="vevent"><p class="date single"><span class="dtstart"><span class="year">2010</span><span class="mm-dd">-02-03</span></span> <span class="paren">(</span><span class="dd-mmm">3 FEB</span><span class="paren">)</span></p>
                                <div class="info-wrap"><p class="summary">Hands on Semantic Web tutorial for developers</p><p class="eventtitle"><a class="uri" href="http://www.w3c.org.il/article/semanticweb">First meeting of The Israeli W3C Developers Forum </a></p><p class="location">Tel-Aviv,
                                    Israel</p></div>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="unit size1on2 lastUnit">
                    <div class="w3c_upcoming_events" id="w3c_home_upcoming_events"><h2 class="category"><a href="/participate/eventscal.html" title="More Events…">Events </a></h2>
                        <ul class="vevent_list">
                            <li class="vevent">
                                <div class="date">
                                    <span class="dtstart"><span class="year">2010</span><span class="mm-dd">-01-26</span></span>
                                    <span class="paren">(</span><span class="dd-mmm">26 JAN</span><span class="paren">)</span>
                                    <span class="date-separator"> &ndash; </span>
                                    <span class="dtend"><span class="year">2010</span><span class="mm-dd">-01-28</span></span>
                                    <span class="paren">(</span><span class="dd-mmm">28 JAN</span><span class="paren">)</span>
                                </div>
                                <div class="info-wrap">
                                    <p class="summary">
                                        <a class="uri" href="http://www.w3.org/2002/ws/ra/">WS-Resource Access WG </a>
                                    </p>
                                    <p class="location">Sunnyvale, CA, USA</p>       <p class="host">Fujitsu</p>
                                </div>
                            </li>
                            <li class="vevent">
                                <div class="date">
                                    <span class="dtstart"><span class="year">2010</span><span class="mm-dd">-03-08</span></span>
                                    <span class="paren">(</span><span class="dd-mmm"> 8 MAR</span><span class="paren">)</span>
                                    <span class="date-separator"> &ndash; </span>
                                    <span class="dtend"><span class="year">2010</span><span class="mm-dd">-03-12</span></span>
                                    <span class="paren">(</span><span class="dd-mmm">12 MAR</span><span class="paren">)</span>
                                </div>
                                <div class="info-wrap">
                                    <p class="summary">
                                        XSL Working Group
                                    </p>
                                    <p class="location">Prague</p>       <p class="host">co-located with XML Prague</p>
                                </div>
                            </li>
                            <li class="vevent">
                                <div class="date">
                                    <span class="dtstart"><span class="year">2010</span><span class="mm-dd">-03-16</span></span>
                                    <span class="paren">(</span><span class="dd-mmm">16 MAR</span><span class="paren">)</span>
                                    <span class="date-separator"> &ndash; </span>
                                    <span class="dtend"><span class="year">2010</span><span class="mm-dd">-03-18</span></span>
                                    <span class="paren">(</span><span class="dd-mmm">18 MAR</span><span class="paren">)</span>
                                </div>
                                <div class="info-wrap">
                                    <p class="summary">
                                        Device APIs and Policy Working Group
                                    </p>
                                    <p class="location"> Prague, Czech Republic</p>       <p class="host"> Charles University</p>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <!-- end events talks --></div>
    <!-- end main content --></div>
<div class="unit size1on3 lastUnit">
    <p class="about">The World Wide Web Consortium (W3C) is an
        international community that develops <a href="/TR/">standards</a>
        to ensure the long-term growth of the Web. Join <a href="Consortium/activities.html">groups</a>, and participate in
        <a href="/blog/">W3C blogs</a> and other <a href="participate/discussion.html">discussion</a>. We welcome your help
        to fulfill the <a href="Consortium/mission.html">W3C mission</a>:
        to lead the Web to its full potential.</p>
    <div id="w3c_home_new_jobs">
        <h2 class="category"><a href="/Consortium/Recruitment/" title="Available positions">Jobs </a></h2>
        <p>W3C is seeking a <a href="/Consortium/Recruitment/">Chief
            Executive Officer</a>; learn more about <a href="/Consortium/Recruitment/">job opportunities</a>.</p>
    </div>
    <div id="w3c_home_recent_blogs"><h2 class="category">
        <a href="/QA/" title="More Blog Entries…">W3C Blog
        </a>
    </h2>
        <ul class="hentry_list">
            <li class="hentry">
                <p class="entry-title">
                    <a rel="bookmark" class="uri url" href="http://www.w3.org/QA/2010/01/swswiki.html">SWSWiki</a>
                </p>
                <p class="date">
                    <abbr class="published" title="2010-01-18">18 January 2010</abbr> by <span class="author vcard">
               <a href="http://www.w3.org/People/Ivan" class="fn url">Ivan Herman</a>
            </span>
                </p>
            </li>
            <li class="hentry">
                <p class="entry-title">
                    <a rel="bookmark" class="uri url" href="http://www.w3.org/QA/2010/01/encourage_accessibility_make_a_difference.html">Take a few minutes to encourage web accessibility. You can make a difference.</a>
                </p>
                <p class="date">
                    <abbr class="published" title="2010-01-06">6 January 2010</abbr> by <span class="author vcard">
               <a href="http://www.w3.org/People/Shawn/" class="fn url">Shawn Henry</a>
            </span>
                </p>
            </li>
            <li class="hentry">
                <p class="entry-title">
                    <a rel="bookmark" class="uri url" href="http://www.w3.org/QA/2009/12/share_resources_supporting_the.html">Share Resources Supporting the Web Accessibility Business Case</a>
                </p>
                <p class="date">
                    <abbr class="published" title="2009-12-14">14 December 2009</abbr> by <span class="author vcard">
               <a href="http://www.w3.org/People/Shawn/" class="fn url">Shawn Henry</a>
            </span>
                </p>
            </li>
        </ul>
    </div>
    <div id="w3c_home_validators_software">
        <h2 class="category"><a href="Status.html">Validators and Other
            Software </a></h2>
        <p>The W3C Community has created useful <a href="Status.html">Open
            Source Software</a>. The most popular is the <a href="http://validator.w3.org/">W3C validator</a>, which can help you
            with <a href="http://validator.w3.org/" title="HTML and XHTML Validator">HTML</a>, <a href="http://jigsaw.w3.org/css-validator/" title="CSS Validator">CSS</a>, <a href="http://validator.w3.org/mobile/" title="mobileOK Checker">mobileOK
                content</a>, and other W3C technologies. Become a <a href="QA/Tools/Donate#donate_sponsors">validator sponsor</a>.
            <strong>New:</strong> the <a href="http://dev.w3.org/2009/cheatsheet/">W3C cheatsheet</a>, for quick
            access to CSS properties, WCAG tips, mobile tips, and more.</p>
        <p><a class="no-border" href="QA/Tools/Donate"></a></p>
    </div>
    <div id="w3c_home_member_testimonials" class="hpmt">
        <h2 class="category"><a href="/Consortium/Member/Testimonial/">W3C
            Member Testimonial </a></h2>
        <div id="w3c_home_member_testimonials_choice"><p>
            <a class="no-border" href="http://www.hitachi.co.jp/" rel="nofollow">

            </a>
        </p><h3>
            <a href="http://www.hitachi.co.jp/" rel="nofollow">Hitachi, Ltd.</a>
        </h3><p>Hitachi will develop and provide technologies, products, services, and solutions, including the needs for ubiquitous computing, secure and safe service platforms, and easy-to-apply service solutions. Hitachi is an active participant in W3C's Web Services and Voice Browser activities.
        </p></div>
        <p class="more"><a href="/Consortium/Member/Testimonial/List">Read
            all member testimonials.</a></p>
    </div>
</div>
</div>
<!-- end main col --></div>
</div>
</div>
</textarea>
<script>
    document.getElementById('test-data-div').innerHTML = document.getElementById('test-data-area').value;
</script>
<div><p id="foo"><span></span></p></div>
<script>
    // Ref: http://ejohn.org/blog/thoughts-on-queryselectorall/
//        var foo = document.getElementById("foo");
//        // should return nothing
//        alert($('div span', foo).length);
//        // will return the SPAN (booo!)
//        alert(foo.querySelectorAll('div span').length);
</script>

<!-- Test Cases -->
<script>
var S = KISSY, DOM = S.DOM, doc = document;

// #id:
function test_query_id_pd(test) {
    var s = 'test-data';
    test.name = '#' + s;
    test.extraMsg = '\t{puredom}';

    if (doc.getElementById(s) !== doc.getElementById('test-data')) test.fail();
}

function test_query_id_ks(test) {
    var s = '#test-data';
    test.name = s;
    test.extraMsg = '\t{kissy}';

    if (S.query(s)[0] !== doc.getElementById('test-data')) test.fail();
}

function test_query_id_jq(test) {
    var s = '#test-data';
    test.name = s;
    test.extraMsg = '\t{jquery}';

    if (jQuery(s)[0] !== doc.getElementById('test-data')) test.fail();
}

function test_query_id_sep(test) {
    test.status = 'sep';
}

// tag:
function test_query_tag_pd(test) {
    var s = 'h3', ret = [];
    test.name = s;
    test.extraMsg = '\t{puredom}';

    ret = doc.getElementsByTagName(s);
    if (ret.length !== 9) test.fail(ret.length);
}

function test_query_tag_ks(test) {
    var s = 'h3', ret = [];
    test.name = s;
    test.extraMsg = '\t{kissy}';

    ret = S.query(s);
    if (ret.length !== 9) test.fail(ret.length);
}

function test_query_tag_jq(test) {
    var s = 'h3', ret = [];
    test.name = s;
    test.extraMsg = '\t{jquery}';

    ret = jQuery(s);
    if (ret.length !== 9) test.fail(ret.length);
}

function test_query_tag_sep(test) {
    test.status = 'sep';
}

// .cls:
function test_query_cls_pd(test) {
    var s = '.headline', ret = [];
    test.name = s;
    test.extraMsg = '\t{puredom}';

    if (doc.querySelectorAll) ret = doc.querySelectorAll(s);
    if (ret.length !== 6) test.fail(ret.length);
}

function test_query_cls_ks(test) {
    var s = '.headline', ret = [];
    test.name = s;
    test.extraMsg = '\t{kissy}';

    ret = S.query(s);
    if (ret.length !== 6) test.fail(ret.length);
}

function test_query_cls_jq(test) {
    var s = '.headline', ret = [];
    test.name = s;
    test.extraMsg = '\t{jquery}';

    ret = jQuery(s);
    if (ret.length !== 6) test.fail(ret.length);
}

function test_query_cls_sep(test) {
    test.status = 'sep';
}

// #id tag:
function test_query_idtag_pd(test) {
    var s = '#test-data a', ret = [];
    test.name = s;
    test.extraMsg = '\t{puredom}';

    if (doc.querySelectorAll) ret = doc.querySelectorAll(s);
    if (ret.length !== 91) test.fail(ret.length);
}

function test_query_idtag_ks(test) {
    var s = '#test-data a', ret = [];
    test.name = s;
    test.extraMsg = '\t{kissy}';

    ret = S.query(s);
    if (ret.length !== 91) test.fail(ret.length);
}

function test_query_idtag_jq(test) {
    var s = '#test-data a', ret = [];
    test.name = s;
    test.extraMsg = '\t{jquery}';

    ret = jQuery(s);
    if (ret.length !== 91) test.fail(ret.length);
}

function test_query_idtag_sep(test) {
    test.status = 'sep';
}

// #id .cls:
function test_query_idcls_pd(test) {
    var s = '#test-data .summary', ret = [];
    test.name = s;
    test.extraMsg = '\t{puredom}';

    if (doc.querySelectorAll) ret = doc.querySelectorAll(s);
    if (ret.length !== 12) test.fail(ret.length);
}

function test_query_idcls_ks(test) {
    var s = '#test-data .summary', ret = [];
    test.name = s;
    test.extraMsg = '\t{kissy}';

    ret = S.query(s);
    if (ret.length !== 12) test.fail(ret.length);
}

function test_query_idcls_jq(test) {
    var s = '#test-data .summary', ret = [];
    test.name = s;
    test.extraMsg = '\t{jquery}';

    ret = jQuery(s);
    if (ret.length !== 12) test.fail(ret.length);
}

function test_query_idcls_sep(test) {
    test.status = 'sep';
}

// tag .cls:
function test_query_tagcls_pd(test) {
    var s = 'div.description', ret = [];
    test.name = s;
    test.extraMsg = '\t{puredom}';

    if (doc.querySelectorAll) ret = doc.querySelectorAll(s);
    if (ret.length !== 6) test.fail(ret.length);
}

function test_query_tagcls_ks(test) {
    var s = 'div.description', ret = [];
    test.name = s;
    test.extraMsg = '\t{kissy}';

    ret = S.query(s);
    if (ret.length !== 6) test.fail(ret.length);
}

function test_query_tagcls_jq(test) {
    var s = 'div.description', ret = [];
    test.name = s;
    test.extraMsg = '\t{jquery}';

    ret = jQuery(s);
    if (ret.length !== 6) test.fail(ret.length);
}

function test_query_tagcls_sep(test) {
    test.status = 'sep';
}

// #id tag.cls:
function test_query_idtagcls_pd(test) {
    var s = '#test-data p.date', ret = [];
    test.name = s;
    test.extraMsg = '\t{puredom}';

    if (doc.querySelectorAll) ret = doc.querySelectorAll(s);
    if (ret.length !== 12) test.fail(ret.length);
}

function test_query_idtagcls_ks(test) {
    var s = '#test-data p.date', ret = [];
    test.name = s;
    test.extraMsg = '\t{kissy}';

    ret = S.query(s);
    if (ret.length !== 12) test.fail(ret.length);
}

function test_query_idtagcls_jq(test) {
    var s = '#test-data p.date', ret = [];
    test.name = s;
    test.extraMsg = '\t{jquery}';

    ret = jQuery(s);
    if (ret.length !== 12) test.fail(ret.length);
}

function test_query_idtagcls_sep(test) {
    test.status = 'sep';
}

// group:
function test_query_group_pd(test) {
    var s = '#test-data .date, #w3c_main .date', ret = [];
    test.name = s;
    test.extraMsg = '\t{puredom}';

    if (doc.querySelectorAll) ret = doc.querySelectorAll(s);
    if (ret.length !== 15) test.fail(ret.length);
}

function test_query_group_ks(test) {
    var s = '#test-data .date, #w3c_main .date', ret = [];
    test.name = s;
    test.extraMsg = '\t{kissy}';

    ret = S.query(s);
    if (ret.length !== 15) test.fail(ret.length);

    if(S.query('div span', '#foo').length !== 0) test.fail();
    if($('div span, p span', '#foo').length !== 1) test.fail();
}

function test_query_group_jq(test) {
    var s = '#test-data .date, #w3c_main .date', ret = [];
    test.name = s;
    test.extraMsg = '\t{jquery}';

    ret = jQuery(s);
    if (ret.length !== 15) test.fail(ret.length);
}

function test_query_group_sep(test) {
    test.status = 'sep';
}

// unsupported selector:
function test_query_unsupported_ks(test) {
    var s = '#w3c_main .line .unit', ret = [];
    test.name = s;
    test.extraMsg = '\t{kissy}';

    ret = S.query(s);
    if (ret.length !== 4) test.fail(ret.length);
}

function test_query_unsupported_jq(test) {
    var s = '#w3c_main .line .unit', ret = [];
    test.name = s;
    test.extraMsg = '\t{jquery}';

    ret = jQuery(s);
    if (ret.length !== 4) test.fail(ret.length);
}

function test_query_unsupported_sep(test) {
    test.status = 'sep';
}

// exceptions:
function test_query_exceptions(test) {

    // 空字符串返回 []
    if (S.query('').length !== 0) test.fail();
    if (S.query('  ').length !== 0) test.fail();

    // 无参数时，返回空数组
    if (S.query().length !== 0) test.fail();

    // 传入 Node 时，返回 [Node]
    if (S.query(doc)[0] !== doc) test.fail();

    // 传入 NodeList 时，返回转换后的数组
    var nodeList = doc.getElementsByTagName('h3');
    if (S.query(nodeList)[0].className !== 'category') test.fail();

    // 允许空白字符
    if (S.query(' #test-data  p.date  ').length !== 12) test.fail();

    // #id.cls
    if (S.query('#test-data.date').length !== 0) test.fail();
    if (S.query('#w3c_logo_shadow.w3c_leftCol').length !== 1) test.fail();

    // context 为 null 时，返回 []
    // 注：这和 jQuery 不同，jQuery 此时会将 context 赋值为 doc
    if (S.query('p', null).length !== 0) test.fail();

    // context 为无效值时，返回 []
    // 注：此时和 jQuery 一致
    if (S.query('p', 1).length !== 0) test.fail();

    // 支持 tag 为 * 号
    if (S.query('*').length < 1) test.fail();
    // ie6 下为 336
    if (S.query('#test-data *').length < 333) test.fail(S.query('#test-data *').length);
    if (S.query('*.date').length !== 15) test.fail();

    // 支持 S.get(window)/S.get(document)
    if(S.get(window) != window) test.fail();
    if(S.get(document) != document) test.fail();
    
}

function test_dom_filter(test) {
    if(DOM.filter('div', '.category').length !== S.query('div.filter').length) test.fail();

    var len = DOM.filter('span', 'h3.category .ribbon').length,
        len2 = S.query('h3.category span.ribbon').length;
    if(len !== len2) test.fail(len  + ' !== ' + len2);

    var len3 = S.query('h3.category span.ribbon').length,
        len4 = DOM.filter('span', function(elem) {
           return DOM.hasClass(elem, 'ribbon');
        }).length;
    if(len3 !== len4) test.fail(len3  + ' !== ' + len4);
}

function test_dom_test(test) {
    if (DOM.test('.cateory', function(elem) {
        return elem.tagName === 'H3';
    })) test.fail();
}

function test_query_each(test) {
    var sum = 0;
    S.query('.date').each(function() {
        sum++;
        if(sum == 7) return false;
    });
    if(sum !== 7) test.fail(sum);
}

</script>
</body>
</html>
